Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add metalsmith build #279

Merged
merged 35 commits into from
Jul 23, 2024
Merged

Add metalsmith build #279

merged 35 commits into from
Jul 23, 2024

Conversation

razor-x
Copy link
Contributor

@razor-x razor-x commented Jul 23, 2024

  • Add TypeScript project structure
  • Add metalsmith
  • Add blueprint and types
  • Add code-sample
  • Add blueprint plugin
  • Add codeSampleDefinitions
  • Add pages from endpoints
  • Only format src
  • Add metalsmith layouts plugin
  • Add empty layouts
  • Add .nvmrc
  • Generate files for sdk and api
  • Move metalsmith items to dependencies
  • Setup layouts

@razor-x razor-x marked this pull request as ready for review July 23, 2024 03:02
@@ -0,0 +1,3 @@
# /acs/systems
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that this should be /acs/systems/list

@kainpets can you see why this is off in blueprint?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, but I forgot to trigger the automatic release of blueprint when I pushed the fix for this. I've manually released yesterday and this should be fixed with version 0.2.1

@@ -0,0 +1,2 @@
# SDK Reference
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file and the other REAMDE can serve as landing pages for each SDK. The content can either live here or we can just generate an index partial to include in the readme via a gitbook include.

src/data/code-sample-definitions/acs-systems.yaml Outdated Show resolved Hide resolved
src/lib/reference.ts Outdated Show resolved Hide resolved
}
const file = files[k] as Partial<TemplateContext>
file.layout = 'api-reference.hbs'
file.endpoint = endpoint
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mastafit We can add something like this instead if we want build a more complicated template context

Suggested change
file.endpoint = endpoint
setFileContext(file)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@razor-x Sure, just give me some requirements for this one, what exactly such function should do?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It depends on what context we need for the template. So if we write the handlebars template and only need endpoint, then we are done. But we may need to extend the context, add to it, or transform it, if endpoint is not enough or hard to use in the template.

Ideally, blueprint would already have what we need so element should be a good context for the template, but at this stage we are still learning what we need in context.

If this gets too complex, we can move logic into handlebars helpers or back into the blueprint.

For example, one thing we want to do is update URLs to be relative in GitBook, e.g., if a description contains a Markdown link to to https://docs.seam.co/latest/core-concepts/overview we really want this to link to ../core-concepts/overview or whatever the correct internal GitBook linking should be.

Another example is we want to generate links to other resources, e.g., The acs_system is... should might get transformed to The [acs_system](../acs_system) is...`.

We can implement those two things later, I'm just using them as an example. But either it would be handled inside setFileContext or in the template via a helper like {{ element.description | linkResources | relativeLinks }}.

This PR does not include registering handlebars helpers, but it should be simple to add that under src/lib.

src/metalsmith.ts Outdated Show resolved Hide resolved
// })
const typesModule = {
...types,
codeSampleDefinitions: (metadata as any).codeSampleDefinitions,
Copy link
Contributor

@andrii-balitskyi andrii-balitskyi Jul 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're passing the path to metadata.codeSampleDefinitions in src/metalsmith.ts:

  .use(
    metadata({
      codeSampleDefinitions: './data/code-sample-definitions',
    }),
  )

I suppose we need to read all the definitions from './data/code-sample-definitions' and pass them instead of the path itself because TypesModuleSchema expects codeSampleDefinitions: z.array(CodeSampleDefinitionSchema).default([]) according to the ongoing blueprint PR?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, TypesModuleSchema has all definitions, and then creates and passes only the code samples specific to each endpoint.

@razor-x razor-x merged commit a242ef4 into main Jul 23, 2024
6 checks passed
@razor-x razor-x deleted the metalsmith branch July 23, 2024 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants